﻿$user=”lang.wang@slbcopower.com”
$passwd=ConvertTo-SecureString -String “**********” -AsPlainText -Force
$cre=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$passwd
$utf8 = [System.Text.Encoding]::GetEncoding(65001)

$iso88591 = [System.Text.Encoding]::GetEncoding(28591)

$src_string = Invoke-RestMethod -Uri http://blog.sina.com.cn/s/blog_48874cec0102wvxh.html  #http://blog.sina.com.cn/s/blog_48874cec0102wvrd.html

$src_bytes = $utf8.GetBytes($src_string)

$des_bytes = [System.Text.Encoding]::Convert($utf8,$iso88591,$src_bytes)

$des_string = $utf8.GetString($des_bytes)
$des_string|Out-File D:\text.txt
$con=Get-Content D:\text.txt
$seg=”(^<p>\d+:\d+.*[\u4e00-\u9f5a]+</p>$)” #正则表达式，^以…开始。\d+数字出现1次及以上，.*匹配所有，[\u4e00-\u9f5a]匹配中文,$以什么结束 正则根据自己的实际需求更改 我这只是个例子 有不完善的自己更改一下
[string]$list=$con -match $seg
Send-MailMessage -From $user -To lang.wang@slbcopower.com -Subject “股票时报” -Body $list -SmtpServer smtp.263.net -Credential $cre -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)



$list=new-object -typename System.Collections.ArrayList #有add方法可变
$array=@(1,2,3,4,5)  #固定大小
foreach($item in $array)  #遍历
{
Write-Host $item
}
$hash=@{Name="wang lang";Age=28;} #哈希表 我常用在查看前后差异
$hash.Name
$hash.Count
$hash.Keys
$hash.Values
$hash["Name"]



Invoke-RestMethod -Uri “http://www.pstips.net” -ContentType ‘application/json;charset=utf-8‘ -Body $body -Method Post


[char][int](Get-Random -Maximum 40869 -Minimum 19968) # 随机汉字